package API.DAY5.io;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyDemo2 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("1.png");
        FileOutputStream fos = new FileOutputStream("1_copy2.png");
        int d;
        byte[] data = new byte[1024*10];
        long start = System.currentTimeMillis();
        while ((d=fis.read(data))!=-1){
            //fos.write(data);//写入整个可能会导致末尾出现脏数据
            fos.write(data,0,d);//从data的0开始写入d个字节，读多少写多少
        }
        long end = System.currentTimeMillis();
        System.out.println("耗时:"+(end-start)+"ms");
        fis.close();
        fos.close();
    }
}
